#ifndef SESSION_H
#define SESSION_H

#include <QObject>
#include <QPoint>
#include <baseview.h>
#include <mainwindow.h>
#include <materialmanager.h>
#include <material_editor/materialview.h>
#include <object_browser/objectbrowserview.h>
#include <object_composer/objectcomposerview.h>
#include <scene_editor/sceneview.h>
#include <QAction>
#include <QStackedWidget>
#include <engine.h>

class iTreeItem;
class Session : public QObject
{
  Q_OBJECT
private:
  enum StackPage
  {
    SP_MaterialView,
    SP_ObjectBrowser,
    SP_ObjectComposer
  };

  static Session* static_instance;

  ceEngine          *_engine;

  MaterialManager*  _materialManager;
  ObjectManager*    _objectManager;

  MainWindow        *_mainWindow;
  QStackedWidget    *_centerStack;
  MaterialView      *_materialView;
  ObjectBrowserView *_objectBrowserView;
  ObjectComposerView* _objectComposerView;
  SceneView         *_sceneView;


  QString           _projectFolder;

  void InitMMData ();

  Session();
  void ChangeStackPage (StackPage page);
  void SetProjectFolder (const QString& projectFolder);
public slots:
  void ShowMaterialView ();
  void ShowMaterialView (Material* material);
  void ShowObjectBrowser ();
  void ShowObjectComposer();

public:
  static Session* Get ();

  bool MakeGLContextCurrent ();

  void Initialize ();
  void Open (const QString& projectFolder);
  const QString& GetProjectFolder () const;

  MaterialManager* GetMaterialManager();
  MainWindow* GetMainWindow ();

  ceEngine* GetEngine ();
  iDevice* GetDevice ();

};

#endif // SESSION_H
